class Solution
{
public:
    int getDis(vector<int>& A, int n)
    {
        int ans, min = A[0];
        for (int i = 0; i < n; i++)
        {
            if (A[i] < min)
                min = A[i];
            ans = max(ans, A[i] - min);
        }
        return ans;
    }
};